package com.eascs.web.o2o.mq.service.impl;

import javax.inject.Inject;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.notify.constant.ModelResult;
import com.eascs.web.o2o.mq.dao.RabbitMqDao;
import com.eascs.web.o2o.mq.entity.RepayMentInfoEntity;
import com.eascs.web.o2o.mq.service.TransService;

public class RepayMentInfoService extends TransAbstractService implements TransService<RepayMentInfoEntity>{

	@Inject 
	RabbitMqDao rabbitMqDao;
	
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());


	@Override
	public ModelResult<Boolean> exec(RepayMentInfoEntity data) {
		ModelResult<Boolean> model= new ModelResult<Boolean>();
		try {
			String sql="update basic_information_after_loan set repay_status = ? ,repay_date = ? where bill_code = ?  ";
			int i=rabbitMqDao.execute(sql, data.getStatus(),data.getRepayMentDate(),data.getBillCode());
			if(i>0){
				writeLog(data.getLoanappyNo(), data.getLoanappyNo(), data.getBillCode(),0,"RepayMent");//消费日志
				model.setModel(true);
			}else{
				model.withError("sql Error", "未找到要更新的数据");
				model.setModel(false);
			}
			
		} catch (Exception e) {
			logger.error("sql Error", e);
			model.withError("sql Error", "脚本执行异常");
			model.setModel(false);
		}
		
		return model;
	}


	@Override
	public String getServiceName() {
		return "RepayMent";
	}

	
}
